from flask import Flask, request, Response
from assistant.main import send_message
from db.chroma_repository import init_index
app = Flask(__name__)

@app.route('/init_index')
def chroma_index():
    init_index()

@app.route('/send_message')
def hello_world():
    message = request.args.get('message', default=None, type=str)
    print(message)
    return send_message(message)
    # def generate():
    #     responses = send_message(message)
    #     # 流式发送数据给客户端
    #     for line in responses:
    #         if line:
    #             yield line.delta
    # # 设置响应头以支持流式传输
    # return Response(generate(), mimetype='text/event-stream')

if __name__ == '__main__':
    app.run(port=5001)
